package com.lzh.blog.admin.controller;


import com.lzh.lzhframework.annotation.LogAnnotation;
import com.lzh.lzhframework.constants.LogType;
import com.lzh.lzhframework.domain.ResponseResult;
import com.lzh.lzhframework.domain.dto.feedback.AddFeedbackDto;
import com.lzh.lzhframework.domain.dto.feedback.QueryFeedbackDto;
import com.lzh.lzhframework.domain.dto.feedback.ReplyFeedbackDto;
import com.lzh.lzhframework.domain.vo.feedback.FeedbackStatusVo;
import com.lzh.lzhframework.domain.vo.feedback.FeedbackTypeVo;
import com.lzh.lzhframework.service.FeedbackService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @Author luzhiheng
 * @Date 2023/11/27 11:27
 */
@RequestMapping("/feedback")
@RestController
public class SysFeedBackController {

    @Resource
    private FeedbackService feedbackService;

    @LogAnnotation(message = "查询反馈列表", operation = LogType.QUERY)
    @PostMapping("/queryFeedbackPage")
    public ResponseResult queryFeedbackPage(@RequestBody QueryFeedbackDto dto) {
        return feedbackService.queryFeedbackPage(dto);
    }

    @LogAnnotation(message = "查询所有反馈状态", operation = LogType.QUERY)
    @GetMapping("/queryFeedbackStatus")
    public ResponseResult queryFeedbackStatus() {
        List<FeedbackStatusVo> feedbackStatusVoList = feedbackService.queryFeedbackStatus();
        return ResponseResult.success(feedbackStatusVoList);
    }

    @LogAnnotation(message = "查询所有反馈类型", operation = LogType.QUERY)
    @GetMapping("/queryFeedbackType")
    public ResponseResult queryFeedbackType() {
        List<FeedbackTypeVo> feedbackType = feedbackService.queryFeedbackType();
        return ResponseResult.success(feedbackType);
    }

    @LogAnnotation(message = "回复反馈", operation = LogType.UPDATE)
    @PostMapping("/replyFeedback")
    public ResponseResult replyFeedback(@Valid @RequestBody ReplyFeedbackDto dto) {
        feedbackService.replyFeedback(dto);
        return ResponseResult.success();
    }

    @LogAnnotation(message = "拒绝反馈", operation = LogType.UPDATE)
    @PutMapping("/rejectFeedback/{id}")
    public ResponseResult rejectFeedback(@PathVariable Long id) {
        feedbackService.rejectFeedback(id);
        return ResponseResult.success();
    }

}
